﻿

myApp.controller("fyFoot",function($rootScope,$scope,$http,$q,$filter,$interval,$timeout,httpService){
	
	$scope.img='images/FLYE.png';
	$scope.engText='Technical support';
	$scope.text='飞叶科技股份有限公司';
	$scope.index=0;
	$scope.event=['10月11日下午，龙湾区在中石油龙湾油库组织开展暴恐突发事件应急处置实战演练','10月12日下午，龙湾区在中石油龙湾油库组织开展暴恐突发事件应急处置实战演练','10月13日下午，龙湾区在中石油龙湾油库组织开展暴恐突发事件应急处置实战演练','10月14日下午，龙湾区在中石油龙湾油库组织开展暴恐突发事件应急处置实战演练'];
	$scope.event.unshift($scope.event[$scope.event.length-1]);
	console.log($scope.event);
	carousel($scope.index,0);
	function  carousel(index,t) {
		$scope.index=index;
		$timeout.cancel($scope.timer);
		$scope.timer=$timeout(function () {
			if($scope.index==$scope.event.length-1){
				$('.event').css({'top':0+'vh'});
				carousel(0,0);
			}
			else {
				$('.event').animate({'top':(index+1)*(-3.8)+'vh'});
				carousel(index+1,5000);
			}
		},t)
	}
	
});

myApp.directive('fyFoot',function(httpService){
	var obj = {
		restrict : "EA",
		priority : 0 ,
		terminal: false,
		template :
		'<div class="footer">\n' +
		'    <img ng-src="{{img}}">\n' +
		'    <div class="text">{{engText}}</div>\n' +
		'    <div class="text">{{text}}</div>\n' +
		'    <div class="emergency">紧急事件:</div>\n' +
		'    <ul class="event" ng-style="{\'height\':event.length*3.8+\'vh\'}">\n' +
		'        <li ng-repeat="item in event track by $index">{{item}}</li>\n' +
		'    </ul>\n' +
		'    <div class="right-text">v1.0.20180123003b</div>\n' +
		'</div>\n',
		replace : false,
		scope : {
			dataUrl:'@',
			sginOutUrl:'@sginOut',
			userName:'=userName'
		},
		//可以是字符串或者函数 (公共逻辑)
		//字符串可以指定控制器名称
		//函数为自己设定控制器逻辑
		controller : "fyFoot",
		link:function (scope,Element,Attrs) {
		
		}
	};
	return obj;
});